<<<<<<< HEAD
<%@page contentType="text/html; charset=utf-8" language="java" pageEncoding="utf-8" %>
=======
<%@page contentType="text/html; charset=utf-8" language="java" %>
>>>>>>> 180ace60693232df69575b4f82fc34aeb3fc90e8
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<!DOCTYPE html>
<html>
  
  <head>
    <meta charset="UTF-8">
    <title>书籍列表</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/back/css/font.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/back/css/xadmin.css">
    <script type="text/javascript" src="${pageContext.request.contextPath}/static/back/js/jquery-3.5.1.js"></script>
    <script src="${pageContext.request.contextPath}/static/back/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/static/back/js/xadmin.js"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
      <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
      <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
  </head>
  
  <body>
    <div class="x-nav">
      <span class="layui-breadcrumb">
        <a href="">首页</a>
        <a href="">书籍</a>
        <a>
          <cite>列表</cite></a>
      </span>
<<<<<<< HEAD
      <a class="layui-btn layui-btn-small" id="refresh" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
=======
      <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
>>>>>>> 180ace60693232df69575b4f82fc34aeb3fc90e8
        <i class="layui-icon" style="line-height:30px">ဂ</i></a>
    </div>
    <div class="x-body">
      <div class="layui-row">
        <form id="searchForm" class="layui-form layui-col-md12 x-so" method="post"
          action="">
<<<<<<< HEAD
          <input type="text" id="bookName" name="bookName"  placeholder="请输入书籍名" autocomplete="off" class="layui-input">
          <button id="search" lay-verify="search" class="layui-btn"  lay-submit="" lay-filter="search"><i class="layui-icon">&#xe615;</i></button>
=======
          <input type="text" id="adminName" name="adminName"  placeholder="请输入书籍名" autocomplete="off" class="layui-input" value="${searchDTO.adminName == null?"":searchDTO.adminName}">
          <button lay-verify="search" class="layui-btn"  lay-submit="" lay-filter="sreach"><i class="layui-icon">&#xe615;</i></button>
>>>>>>> 180ace60693232df69575b4f82fc34aeb3fc90e8
        </form>
      </div>
      <xblock>
        <button class="layui-btn layui-btn-danger" onclick="delAll()"><i class="layui-icon"></i>批量删除</button>
        <button class="layui-btn" onclick="x_admin_show('添加书籍','${pageContext.request.contextPath}/back/addview')"><i class="layui-icon"></i>添加</button>
        <span class="x-right" style="line-height:40px">共有数据：${pageInfo.total}条</span>
      </xblock>
      <table class="layui-table">
        <thead>
          <tr>
            <th>
              <div class="layui-unselect header layui-form-checkbox" lay-skin="primary"><i class="layui-icon">&#xe605;</i></div>
            </th>
            <th>ID</th>
            <th>图片</th>
            <th>书籍名称</th>
            <th>作者</th>
            <th>出版社</th>
            <th>出版时间</th>
            <th>价格</th>
            <th>类型</th>
            <th>操作</th>
        </thead>
        <tbody>
          <c:forEach items="${pageInfo.list}" var="book">
            <tr>
              <td>
<<<<<<< HEAD
                <div class="layui-unselect layui-form-checkbox ${book.checked == 1 ? 'layui-form-checked' : ''}" lay-skin="primary" data-id='${book.id}'><i class="layui-icon">&#xe605;</i></div>
=======
                <div class="layui-unselect layui-form-checkbox" lay-skin="primary" data-id='${book.id}'><i class="layui-icon">&#xe605;</i></div>
>>>>>>> 180ace60693232df69575b4f82fc34aeb3fc90e8
              </td>
              <td>${book.id}</td>
              <td>
                <c:if test="${!empty book.img}">
<<<<<<< HEAD
                  <img onclick="showImg(this,'${book.bookName}')" src="${pageContext.request.contextPath}/${book.img}" style="width:auto;height:auto;max-width:100%;max-height: 35px"/>
=======
                  <img onclick="showImg(this,'${book.bookName}')" src="${book.img}" style="width:auto;height:auto;max-width:100%;max-height: 35px"/>
>>>>>>> 180ace60693232df69575b4f82fc34aeb3fc90e8
                </c:if>
              </td>
              <td>${book.bookName}</td>
              <td>${book.author}</td>
              <td>${book.publisher}</td>
              <td><fmt:formatDate value="${book.publishTime}" pattern="yyyy-MM-dd"/></td>
              <td>${book.price}</td>
              <td>${book.bookCategory.categoryName}</td>
              <td class="td-manage">
<<<<<<< HEAD
                <a title="编辑"  onclick="x_admin_show('编辑','${pageContext.request.contextPath}/back/updateView?id=${book.id}')">
=======
                <a title="编辑"  onclick="x_admin_show('编辑','${pageContext.request.contextPath}/back/showupdatebook?id=${book.id}')" href="javascript:;">
>>>>>>> 180ace60693232df69575b4f82fc34aeb3fc90e8
                  <i class="layui-icon">&#xe642;</i>
                </a>
                <a title="删除" onclick="member_del(this,${book.id})" href="javascript:;">
                  <i class="layui-icon">&#xe640;</i>
                </a>
              </td>
            </tr>
          </c:forEach>
        </tbody>
      </table>
      <div class="page">
        <div>
          <c:if test="${pageInfo.hasPreviousPage}">
            <a class="prev" href="${pageContext.request.contextPath}/back/booklist?start=${pageInfo.prePage}">&lt;&lt;</a>
          </c:if>
          <c:forEach items="${pageInfo.navigatepageNums}" var="numb">
            <c:if test="${pageInfo.pageNum == numb}">
              <span class="current">${numb}</span>
            </c:if>
            <c:if test="${pageInfo.pageNum != numb}">
<<<<<<< HEAD
              <a class="num" href="${pageContext.request.contextPath}/back/booklist?start=${numb}&bookName=${pageContext.request.getAttribute("bookName")}">${numb}</a>
            </c:if>
          </c:forEach>
          <c:if test="${pageInfo.hasNextPage}">
            <a class="next" href="${pageContext.request.contextPath}/back/booklist?start=${pageInfo.nextPage}&bookName=${pageContext.request.getAttribute("bookName")}">&gt;&gt;</a>
=======
              <a class="num" href="${pageContext.request.contextPath}/back/booklist?start=${numb}">${numb}</a>
            </c:if>
          </c:forEach>
          <c:if test="${pageInfo.hasNextPage}">
            <a class="next" href="${pageContext.request.contextPath}/back/booklist?start=${pageInfo.nextPage}">&gt;&gt;</a>
>>>>>>> 180ace60693232df69575b4f82fc34aeb3fc90e8
          </c:if>
        </div>
      </div>

    </div>
    <script>
      layui.use('laydate', function(){
        var laydate = layui.laydate;
        //执行一个laydate实例
        laydate.render({
          elem: '#',//指定元素
          format:'yyyy-MM-dd'
        });
      });

      layui.use('form',function () {
        var form = layui.form;
<<<<<<< HEAD
        /!*自定义表单验证*!/
=======
        /*自定义表单验证*/
>>>>>>> 180ace60693232df69575b4f82fc34aeb3fc90e8
        form.verify({
          search:function () {
            if ($("#start").val() == "" && $("#end").val() == "" && $("#adminName").val() == ""){
              $("#searchForm").attr('action','${pageContext.request.contextPath}/admin/index?m=list')
            }
            if ($("#start").val() != "" && $("#end").val() != ""){
              var startTime = new Date($("#start").val()).getTime();
              var endTime = new Date($("#end").val()).getTime();
              if (startTime>=endTime){
                return "开始日不能大于截至日!";
              }
            }
          }
        })
      })

       /*用户-停用*/
      function member_stop(obj,adminName){
          var msg;
          if ($(obj).attr('title') == '启用'){
            msg = "确认要停用吗?"
          }else{
            msg = "确认要启用吗?"
          }
          layer.confirm(msg,function(index){
              if($(obj).attr('title')=='启用'){
                 $.ajax({
                   url:"${pageContext.request.contextPath}/admin/index?m=updateStatus",
                   type:"post",
                   data:"adminName="+adminName,
                   dataType:"json",
                   success:function (res) {
                     if (res.code == 200){
                       $(obj).attr('title','停用')
                       $(obj).find('i').html('&#xe62f;');
                       $(obj).parents("tr").find(".td-status").find('span').addClass('layui-btn-disabled').html('已停用');
                       layer.msg('已停用!',{icon: 5,time:1000});
                     }
                   }
                 })
              }else{
                $.ajax({
                  url:"${pageContext.request.contextPath}/admin/index?m=updateStatus",
                  type:"post",
                  data:"adminName="+adminName,
                  dataType:"json",
                  success:function (res) {
                    if (res.code == 200){
                      $(obj).attr('title','启用')
                      $(obj).find('i').html('&#xe601;');
                      $(obj).parents("tr").find(".td-status").find('span').removeClass('layui-btn-disabled').html('已启用');
                      layer.msg('已启用!',{icon: 1,time:1000});
                    }
                  }
                })
              }
          });
      }

      /*删除*/
      function member_del(obj,id){
          layer.confirm('确认要删除吗？',function(index){
              //发异步删除数据
              $.ajax({
<<<<<<< HEAD
                url:"${pageContext.request.contextPath}/back/deleteById",
=======
                url:"${pageContext.request.contextPath}/back/delOneBook",
>>>>>>> 180ace60693232df69575b4f82fc34aeb3fc90e8
                type:"post",
                data:"id="+id,
                dataType:"json",
                success:function (res) {
<<<<<<< HEAD
                  if (res.code == 100){
                    $(obj).parents("tr").remove();
                    layer.msg('已删除!',{icon:1,time:1000});
                    window.location.replace(location.href);
                  }
                  // layer.msg(res.msg,function () {
                  //   if (res.code == 100){
                  //     $(obj).parents("tr").remove();
                  //     layer.msg('已删除!',{icon:1,time:1000});
                  //   }
                  // })
=======
                  layer.msg(res.msg,function () {
                    if (res.code == 100){
                      $(obj).parents("tr").remove();
                      layer.msg('已删除!',{icon:1,time:1000});
                    }else if(res.code == 101){
                      layer.msg('删除失败!',{icon:1,time:1000});
                    }
                  })
>>>>>>> 180ace60693232df69575b4f82fc34aeb3fc90e8
                }
              })
          });
      }

<<<<<<< HEAD
=======


>>>>>>> 180ace60693232df69575b4f82fc34aeb3fc90e8
      function delAll (argument) {

        var ids = tableCheck.getData();
        if (ids.length == 0){
          layer.msg("请选择要删除的用户!",{icon:0,time:2000})
          return;
        }
        layer.confirm('确认要删除吗？',function(index){
            $.ajax({
<<<<<<< HEAD
              url:"${pageContext.request.contextPath}/back/deleteList",
=======
              url:"${pageContext.request.contextPath}/admin/index?m=batchDelete",
>>>>>>> 180ace60693232df69575b4f82fc34aeb3fc90e8
              type:"post",
              data:"ids="+ids,
              dataType:"json",
              success:function (res) {
<<<<<<< HEAD
                if (res.code == 100){
                  //捉到所有被选中的，发异步进行删除
                  layer.msg('删除成功', {icon: 1});
                  $(".layui-form-checked").not('.header').parents('tr').remove();
                  window.location.replace(location.href);
                }
=======
                layer.msg(res.msg,function () {
                  if (res.code == 200){
                    //捉到所有被选中的，发异步进行删除
                    layer.msg('删除成功', {icon: 1});
                    $(".layui-form-checked").not('.header').parents('tr').remove();
                  }
                })
>>>>>>> 180ace60693232df69575b4f82fc34aeb3fc90e8
              }
            })
        });
      }

      function showImg(obj,bookName) {
        var imgHtml = "<img src='"+obj.src+"' style='width: auto;height: auto;max-width: 100%;max-height: 450px'/>"
        layer.open({
          type:1,
          shade:0.5,
          area:['auto',500+'px'],
          shadeClose:true,
          title:bookName+"  预览",
          content:imgHtml
        })
      }
<<<<<<< HEAD

=======
>>>>>>> 180ace60693232df69575b4f82fc34aeb3fc90e8
    </script>

  </body>

</html>